package hihocode;

import java.util.Arrays;
import java.util.HashMap;
import java.util.Scanner;

//1514 偶像的条件
public class ThreeNumber {

//	public static void main(String[] args) {
//		int[] nums = {1, 6, 9, 10, 16, 18};
//		System.out.println(binarySearch(nums, 0, nums.length - 1, 20));
//	}
	
	public static void mainWrong(String[] args) {
		Scanner scanner = new Scanner(System.in);
		int m, n, l;
		int[] a, b ,c;
		HashMap<Integer, Boolean> amap = new HashMap<>();
		HashMap<Integer, Boolean> bmap = new HashMap<>();
		HashMap<Integer, Boolean> cmap = new HashMap<>();
		label:
		while(scanner.hasNext()){
			n = scanner.nextInt();
			m = scanner.nextInt();
			l = scanner.nextInt();
			a = new int[n];
			b = new int[m];
			c = new int[l];
			for(int i = 0; i < a.length; i++){
				a[i] = scanner.nextInt();
				amap.put(a[i], true);
			}
			for(int i = 0; i < b.length; i++){
				b[i] = scanner.nextInt();
				bmap.put(b[i], true);
			}
			for(int i = 0; i < c.length; i++){
				c[i] = scanner.nextInt();
				cmap.put(c[i], true);
			}
			Arrays.sort(a);
			Arrays.sort(b);
			Arrays.sort(c);
			int min = Integer.MAX_VALUE;
			
			//枚举a[i],然后二分查找最接近a[i]的b[i]和c[i]
			for(int i = 0; i < a.length; i++){
				if(bmap.containsKey(a[i]) && cmap.containsKey(a[i])){
					System.out.println(0);
					continue label;
				}else if(bmap.containsKey(a[i])){
					//如果b中含有a[i]
					//那么我们只需要找c数组中最近的
					//因为我们的二分是找到的最小的大于num值得，所以我们要判断返回的下标
					//其实这个应该在binarySearch里面完成的逻辑
					int index = binarySearch(c, 0, c.length - 1, a[i]);
					int diff = Integer.MAX_VALUE;
					if(index == 0 || index == c.length){
						diff = index == 0 ? c[index] - a[i] : a[i] - c[index - 1];
					}else{
						diff = Math.min(Math.abs(c[index] - a[i]), Math.abs(a[i] - c[index - 1]));
					}
					min = Math.min(min, 2 * diff);
				}else if(cmap.containsKey(a[i])){
					int index = binarySearch(b, 0, b.length - 1, a[i]);
					int diff = Integer.MAX_VALUE;
					if(index == 0 || index == b.length){
						diff = index == 0 ? b[index] - a[i] : a[i] - b[index - 1];
					}else{
						diff = Math.min(Math.abs(b[index] - a[i]), Math.abs(a[i] - b[index - 1]));
						//System.out.println("the diff: " + diff);
					}
					min = Math.min(min, 2 * diff);
				}else{
					//如果都不含的话，就查找b[i],然后再查找c[i]
					int index = binarySearch(b, 0, b.length - 1, a[i]);
					//bNum表示离a[i]最近的数
					int bNum = index == b.length ? b[index - 1] : b[index];
					if(index != 0 && index != b.length){
						if(Math.abs(b[index] - a[i]) > Math.abs(a[i] - b[index - 1])){
							bNum = b[index - 1];
						}
					}
					int cIndex = binarySearch(c, 0, c.length - 1, a[i]);
					if(cIndex == c.length){
						cIndex = cIndex - 1;
					}
					if(bNum > a[i]){
						if(c[cIndex] >= a[i] && c[cIndex] <= bNum){
							min = Math.min(min, 2 * Math.abs(bNum - a[i]));
							continue;
						}
					}else{
						if(c[cIndex] <= a[i] && c[cIndex] >= bNum){
							min = Math.min(min, 2 * Math.abs(bNum - a[i]));
							continue;
						}
					}
					
					int diff = 0;
					if(cIndex == 0){
						if(bNum > a[i]){
							diff = Math.abs(c[cIndex] - bNum);
						}else{
							diff = Math.abs(c[cIndex] - a[i]);
						}
					}else{
						if(c[cIndex] < a[i]){
							if(bNum < a[i]){
								diff = Math.abs(c[cIndex] - bNum);
							}else{
								diff = Math.abs(c[cIndex] - a[i]);
							}
						}else{
							if(bNum > a[i]){
								diff = Math.min(Math.abs(c[cIndex] - bNum), Math.abs(a[i] - c[cIndex - 1]));
							}else{
								diff = Math.min(Math.abs(c[cIndex] - a[i]), Math.abs(bNum - c[cIndex - 1]));
							}
						}
					}
					//System.out.println("cur the diff: " + diff);
					min = Math.min(min, 2 * Math.abs((bNum - a[i])) + 2 * diff);
				}
			}
			System.out.println(min);
		}
		scanner.close();
	}
	
	
	// Runtime: 7923ms
	public static void main(String[] args) {
		Scanner scanner = new Scanner(System.in);
		int m, n, l;
		int[] a, b ,c;
		HashMap<Integer, Boolean> amap = new HashMap<>();
		HashMap<Integer, Boolean> bmap = new HashMap<>();
		HashMap<Integer, Boolean> cmap = new HashMap<>();
		label:
		while(scanner.hasNext()){
			n = scanner.nextInt();
			m = scanner.nextInt();
			l = scanner.nextInt();
			a = new int[n];
			b = new int[m];
			c = new int[l];
			for(int i = 0; i < a.length; i++){
				a[i] = scanner.nextInt();
				amap.put(a[i], true);
			}
			for(int i = 0; i < b.length; i++){
				b[i] = scanner.nextInt();
				bmap.put(b[i], true);
			}
			for(int i = 0; i < c.length; i++){
				c[i] = scanner.nextInt();
				cmap.put(c[i], true);
			}
			Arrays.sort(a);
			Arrays.sort(b);
			Arrays.sort(c);
			int min = Integer.MAX_VALUE;
			
			//枚举a[i],然后二分查找最接近a[i]的b[i]和c[i]
			for(int i = 0; i < a.length; i++){
				if(bmap.containsKey(a[i]) && cmap.containsKey(a[i])){
					System.out.println(0);
					continue label;
				}else if(bmap.containsKey(a[i])){
					//如果b中含有a[i]
					//那么我们只需要找c数组中最近的
					//因为我们的二分是找到的最小的大于num值得，所以我们要判断返回的下标
					//其实这个应该在binarySearch里面完成的逻辑
					int index = binarySearchClose(c, 0, c.length - 1, a[i]);
					int diff = Math.abs(c[index] - a[i]);
					min = Math.min(min, 2 * diff);
				}else if(cmap.containsKey(a[i])){
					int index = binarySearchClose(b, 0, b.length - 1, a[i]);
					int diff = Math.abs(b[index] - a[i]);
					min = Math.min(min, 2 * diff);
				}else{
					//如果都不含的话，就查找b[i],然后再查找c[i]
					int index = binarySearchClose(b, 0, b.length - 1, a[i]);
					//bNum表示离a[i]最近的数
					int bNum = b[index];
					
					int cIndex = binarySearchClose(c, 0, c.length - 1, a[i]);
					int cNum = c[cIndex];
					
					int diff = Math.abs(cNum - bNum) + Math.abs(cNum - a[i]) + Math.abs(bNum - a[i]);
					
					min = Math.min(min, diff);
				}
			}
			System.out.println(min);
		}
		scanner.close();
	}
	
	//找第一个大于等于的
	public static int binarySearch(int[] nums, int left, int right, int target){
		if(left > right){
			return -1;
		}
		int middle;
		if(nums[right] < target){
			return right + 1;
		}
		while(left < right){
			middle = left + (right - left) / 2;
			if(nums[middle] < target){
				left = middle + 1;
			}else{
				right = middle;
			}
		}
		return left;
	}
	
	
	//找最接近的下标
	public static int binarySearchClose(int[] nums, int left, int right, int target){
		if(left > right){
			return -1;
		}
		int middle;
		if(nums[right] < target){
			return right;
		}
		while(left < right){
			middle = left + (right - left) / 2;
			if(nums[middle] < target){
				left = middle + 1;
			}else{
				right = middle;
			}
		}
		//我们此时的left代表的是大于等于target的最小值
		if(left == 0){
			return left;
		}else{
			if(Math.abs(nums[left - 1] - target) < Math.abs(nums[left] - target)){
				return left - 1;
			}else{
				return left;
			}
		}
	}
}
